package com.ktjiaotu.examples;

import com.ktjiaotu.pojo.Person;

import java.lang.reflect.Field;

/**
 * @Author: DABINGCHNEGJIAO
 * @CreateTime: 2025-06-04
 * @Description:
 * @Version: 1.0
 */
public class FieldInfo {
    public static void main(String[] args) {
        try {
            Class pcs = Person.class;
            Object o = pcs.newInstance();
            Field address = pcs.getDeclaredField("address");
            address.setAccessible(true);
            System.out.println("赋值前:" + address.get(o));
            address.set(o, "new address");
            System.out.println("赋值后:" + address.get(o));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
